package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketClass;
import cn.icanci.ladybird.dao.TicketClassDao;
import cn.icanci.ladybird.service.TicketClassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketClass)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:43:45
 */
@Service("ticketClassService")
public class TicketClassServiceImpl implements TicketClassService {
    @Resource
    private TicketClassDao ticketClassDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketClassId 主键
     * @return 实例对象
     */
    @Override
    public TicketClass queryById(Long ticketClassId) {
        return this.ticketClassDao.queryById(ticketClassId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketClass> queryAllByLimit(int offset, int limit) {
        return this.ticketClassDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketClass 实例对象
     * @return 实例对象
     */
    @Override
    public TicketClass insert(TicketClass ticketClass) {
        this.ticketClassDao.insert(ticketClass);
        return ticketClass;
    }

    /**
     * 修改数据
     *
     * @param ticketClass 实例对象
     * @return 实例对象
     */
    @Override
    public TicketClass update(TicketClass ticketClass) {
        this.ticketClassDao.update(ticketClass);
        return this.queryById(ticketClass.getTicketClassId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketClassId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketClassId) {
        return this.ticketClassDao.deleteById(ticketClassId) > 0;
    }
}